﻿package mortal.game.scene3D
{
    import __AS3__.vec.*;
    import baseEngine.system.*;
    import flash.display3D.*;
    import flash.geom.*;
    import frEngine.core.*;
    import frEngine.shader.registType.base.*;
    import mortal.game.scene3D.layer3D.utils.*;

    public class GameCamera extends OrthographicCamera3D
    {
        public var y2d:Number = 0;
        public var x2d:Number = 0;
        private var offset2dy:Number = 0;
        private var yHeight:int = 1000;
        public var center2dx:int = 0;
        public var center2dy:int = 0;

        public function GameCamera(param1:String = "", param2:Number = 75)
        {
            super(param1, param2, 1, 1000000);
            this.zoom = 1;
            this.offset2dy = this.yHeight * Scene3DUtil.cameraAngleCos;
            this.rotationX = Scene3DUtil.cameraAngle;
            this.setBasePosValue(0, this.yHeight, 0);
            return;
        }// end function

        override public function set y(param1:Number) : void
        {
            this.offset2dy = param1 * Scene3DUtil.cameraAngleCos;
            this.setBasePosValue(this.x, param1, this.z);
            return;
        }// end function

        override public function setShakeValue(param1:Number, param2:Number, param3:Number) : void
        {
            super.setShakeValue(param1, param2, param3);
            this.uploadPos();
            return;
        }// end function

        private function uploadPos() : void
        {
            var _loc_3:ConstParamBase = null;
            var _loc_1:* = Scene3DUtil.change3Dto2D(this._shakePos);
            var _loc_2:* = Device3D.viewPortWH;
            _loc_2[2] = this.center2dx + _loc_1.x;
            _loc_2[3] = this.center2dy + _loc_1.y;
            if (scene.context)
            {
                _loc_3 = Device3D.VcConst1Register2;
                scene.context.setProgramConstantsFromVector(Context3DProgramType.VERTEX, _loc_3.index, _loc_3.value, 1);
            }
            return;
        }// end function

        public function setScreenPos(param1:Rectangle) : void
        {
            this.x2d = param1.x;
            this.y2d = param1.y;
            this.center2dx = param1.x + param1.width / 2;
            this.center2dy = param1.y + param1.height / 2;
            var _loc_2:* = Scene3DUtil.change2Dto3DX(this.center2dx);
            var _loc_3:* = Scene3DUtil.change2Dto3DY(this.center2dy + this.offset2dy);
            this.setBasePosValue(_loc_2, this.y, _loc_3);
            this.uploadPos();
            return;
        }// end function

    }
}
